<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function mathFactory(type){  //函数工厂，根据不同的参数返回不同的函数
            return function(m,n){
                return type=="+"?m+n:m-n;
            }
        }

        var add=mathFactory("+");
        console.log(add(100,100));
        
        console.log(mathFactory("-")(300,200));
    </script>
</body>
</html>